package com.budwk.app.enterprise.services.impl;

import com.budwk.app.enterprise.models.SpecialProtectionProject;
import com.budwk.app.enterprise.services.SpecialProtectionProjectService;
import com.budwk.app.miniapp.utils.StringUtils;
import com.budwk.starter.common.page.PageUtil;
import com.budwk.starter.common.page.Pagination;
import com.budwk.starter.common.result.Result;
import com.budwk.starter.database.service.BaseServiceImpl;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.util.cri.SqlExpressionGroup;
import org.nutz.ioc.loader.annotation.IocBean;

@IocBean(args = {"refer:dao"})
public class SpecialProtectionProjectServiceImpl extends BaseServiceImpl<SpecialProtectionProject> implements SpecialProtectionProjectService {
    public SpecialProtectionProjectServiceImpl(Dao dao) {
        super(dao);
    }

    @Override
    public Pagination listByPage(SpecialProtectionProject bean) {
        Cnd cnd = Cnd.NEW();
        SqlExpressionGroup where = cnd.where();
        if (StringUtils.isNotBlank(bean.getPageOrderName()) && StringUtils.isNotBlank(bean.getPageOrderBy())) {
            cnd.orderBy(bean.getPageOrderName(), PageUtil.getOrder(bean.getPageOrderBy()));
        }
        Pagination pagination = listPage(bean.getPageNo(), bean.getPageSize(), cnd);
        return pagination;
    }
}
